
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
	<html>

	<head>
		<meta charset="utf-8">
		<title>定向解答</title>
		<link href="css/myui.css" rel="stylesheet" />
		<link rel="stylesheet" href="css/mui.min.css">
		<link rel="stylesheet" href="css/myui.css">
		<style type="text/css">
			html,body{
				background: #f5f5f5;
			}
			.reservation_content{
				position: absolute;
			    z-index: 2;
			    top: 0;
			    bottom: 0;
			    left: 0;
			    overflow: hidden;
			    width: 100%;
			    margin-top: 3rem;
			}
			.reservation_content1_content{
			    font-size: 0.6rem;
			    margin-bottom: 0.5rem;
			}
			.mui-table-view{
				background: #f5f5f5;	
			}
		</style>
		<script src="js/mui.min.js"></script>
		<script type="text/javascript" src="js/jquery-1.9.0.js"></script>
		<script type="text/javascript" charset="utf-8">
			mui.init();
		</script>
	</head>

	<body>

		<div id="app" class="mui-views" data-view="1">
			<div class="mui-view">
				<div class="mui-navbar">
					<div class="mui-navbar-inner mui-bar mui-bar-nav mui-navbar-center">
						<button type="button" class="mui-left mui-action-back mui-btn  mui-btn-link mui-btn-nav mui-pull-left mui-pull-left_style">
							<span class="mui-icon mui-icon-left-nav"></span>
						</button>
						<h1 class="mui-center mui-title mui-title_fff" style="margin-left: -15px;">定向解答</h1>
					</div>
				</div>
				<div class="mui-pages">
					<div id="setting" class="mui-page mui-page-center">
			<!--页面主内容区结束-->
					</div>
				</div>
			</div>
		</div>

		<div class="reservation_content" id="pullrefresh">
			<div class="mui-scroll">
				<ul class="mui-table-view mui-table-view-chevron wh_plaza_content">
				</ul>
			</div>
		</div>
				
		
	</body>
	
	
	<script src="js/index.js"></script>
	<script src="js/jquery-1.9.0.js"></script>
	<script type="text/javascript">
			mui.init({
				 gestureConfig:{
   					tap: true, //默认为true
   			},
				pullRefresh: {
					container: '#pullrefresh',
					up: {
						contentrefresh: '正在加载...',
						callback: pullupRefresh
					}
				}
			});
			
			mui('.reservation_content').scroll();

			$(".mui-scrollbar").css("display","none");

			var count = 0;
			var phoneNum = "";
			mui.plusReady(function(){
				phoneNum = localStorage.getItem("phoneNum");
			});
			/**
			 * 上拉加载具体业务实现
			 */
			function pullupRefresh() {
				setTimeout(function() {
					mui('#pullrefresh').pullRefresh().endPullupToRefresh(false); //参数为true代表没有更多数据了。
					var url = get_url() + 'questionAnswer/qList/' + phoneNum + '/2';
					var table = document.body.querySelector('.mui-table-view');
					var count_length = 10;
					var count_json;
					$.ajax({
						type: "post",
						dataType: "json",
						url: url,
						data: {"pageIndex":count,"pageSize":count_length},
						success: function(json){
							console.log(json);
							count++;
							if(json == null	|| json == ""){
								mui('#pullrefresh').pullRefresh().endPullupToRefresh(true);
								$(".mui-pull-bottom-pocket").css("visibility","inherit");
								return count;
							}
							for (var i = 0; i < json.length; i++) {
								var li = document.createElement('li');
								var imgPath = json[i].imgPath = ""?json[i].imgPath:'img/touxiang.png';
								var userName=json[i].CREATEUSER.substr(0,3)+'*******'+json[i].CREATEUSER.substr(9,11);
								if(json[i].answerCount > 0){
									li.innerHTML = '<div class="reservation_content1" data-url="answer_details.html?id='+json[i].ID +'">'+
													'<div class="reservation_content1_title">'+
														'<div class="reservation_content1_title_left">'+
															'<img src="'+ imgPath +'">'+
														'</div>'+
														'<div class="reservation_content1_title_right">'+
															'<p>'+ userName +'</p>'+
															'<p>'+ json[i].CREATETIME +'</p>'+
														'</div>'+
													'</div>'+
													'<div class="reservation_content1_content">'+json[i].CONTENT+
													'</div>'+
													'<a href="javascript:;" class="reservation_content1_a">已解答</a>'+
												'</div>';
								}else{
									li.innerHTML = '<div class="reservation_content1" data-url="answer_details.html?id='+json[i].ID +'">'+
													'<div class="reservation_content1_title">'+
														'<div class="reservation_content1_title_left">'+
															'<img src="img/touxiang.png">'+
														'</div>'+
														'<div class="reservation_content1_title_right">'+
															'<p>'+ userName +'</p>'+
															'<p>'+ json[i].CREATETIME +'</p>'+
														'</div>'+
													'</div>'+
													'<div class="reservation_content1_content">'+json[i].CONTENT+
													'</div>'+
													'<a href="javascript:;">待解答</a>'+
												'</div>';
								}
								count_json = li;
								table.appendChild(li);
								var DomMui = count_json.children[0];
								DomMui.addEventListener('tap', function(){
									mui.openWindow({
									    url: $(this).data('url'),
									    id:'answer_details.html',
									    createNew:false,//是否重复创建同样id的webview，默认为false:不重复创建，直接显示
									    waiting:{
									      autoShow:true,//自动显示等待框，默认为true
									      title:'正在加载...',//等待对话框上显示的提示内容
									    }
									});
								});
							}
							var HrHeight = $(".wh_plaza_content2_list").outerHeight();
							var plaza_listLength = $(".wh_plaza_content2_list").length;
							var ClassName = $(".wh_plaza_content2_list").children("hr").length;
							for (var i = 0; i < plaza_listLength; i++) {
								var list_EQ = $(".wh_plaza_content2_list:eq("+ i +")").outerHeight();
								$(".wh_plaza_content2_list:eq("+ i +")").children("hr").attr("size",list_EQ);
							}
						},
						error: function(jqXHR, textStatus, errorThrown) {
							mui.plusReady(function(){
									document.addEventListener("netchange", wainshow, false);
									wainshow();
								//message();
								});
								function wainshow() {
									if (plus.networkinfo.getCurrentType() == plus.networkinfo.CONNECTION_NONE) {
									mui.toast("网络异常，请检查网络设置！");				
									} else {
									//mui.toast("网络正常");
									}
								}
						}
					});
				},1500);
			}
			if (mui.os.plus) {
				mui.plusReady(function() {
					setTimeout(function() {
						mui('#pullrefresh').pullRefresh().pullupLoading();
					}, 1000);

				});
			} else {
				mui.ready(function() {
					mui('#pullrefresh').pullRefresh().pullupLoading();
				});
			}
		
		var view = viewApi.view;
		(function($) {
			//处理view的后退与webview后退
			var oldBack = $.back;
			$.back = function() {
				if (viewApi.canBack()) { //如果view可以后退，则执行view的后退
					viewApi.back();
				} else { //执行webview后退
					oldBack();
				}
			};
			//监听页面切换事件方案1,通过view元素监听所有页面切换事件，目前提供pageBeforeShow|pageShow|pageBeforeBack|pageBack四种事件(before事件为动画开始前触发)
			//第一个参数为事件名称，第二个参数为事件回调，其中e.detail.page为当前页面的html对象
			view.addEventListener('pageBeforeShow', function(e) {
				//				console.log(e.detail.page.id + ' beforeShow');
			});
			view.addEventListener('pageShow', function(e) {
				//				console.log(e.detail.page.id + ' show');
			});
			view.addEventListener('pageBeforeBack', function(e) {
				//				console.log(e.detail.page.id + ' beforeBack');
			});
			view.addEventListener('pageBack', function(e) {
				//				console.log(e.detail.page.id + ' back');
			});
		})(mui);
		
	</script>
	</html>